#ifndef RoModule__h
#define RoModule__h


#include <QtNetwork>

#include "romashka.h"
#include "RoAbstractModule.h"


class RoModule:
    public RoAbstractModule
{
    Q_OBJECT
    
public:
    
    typedef RoAbstractModule super;
    
    RoModule(QObject * parent = 0, bool logTraffic = false);
    ~RoModule();

    virtual bool connectToNetwork(const QString & hostName, quint16 port = ROMASHKA_STANDARD_PORT);

    virtual RoStanzaId sendStanza(RoStanza stanza);

public slots:

    virtual void disconnectFromNetwork();

    virtual bool isConnected() const;

signals:

    void connected();
    void disconnected();
    void error(QAbstractSocket::SocketError);

private:
    
    QPointer<QTcpSocket> transport;
    QPointer<RoXmlStream> _stream;

private slots:

    void openXmlStream();

    void closeXmlStream();

    void announceComponents();

    virtual void recieve_stanza(RoStanza stanza);

}; // class RoModule


#endif // RoModule__h
